package DataStructure.set.TreeSet;

import java.util.Set;
import java.util.TreeSet;

public class TreeSetTest3 {
    public static void main(String[] args) {
        //创建TreeSet容器的时候需要给定比较器对象
        Set<Student> set = new TreeSet<>(new StudentCompareto());

        Student student1 = new Student("张三", 20);
        Student student2 = new Student("张三1", 20);
        Student student3 = new Student("张三2", 20);
        Student student4 = new Student("张三3", 20);

        set.add(student1);
        set.add(student2);
        set.add(student3);
        set.add(student4);

        for(Student student:set){
            System.out.println(student);
        }


    }
}
